# -*- coding: utf-8 -*-
from datetime import timedelta
from spmi.ods.mysql.ibk import spmi_ods__ibk_sz_bill_config
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

spmi_dim__dim_ibk_sz_bill_config_base = SparkSqlOperator(
    task_id='spmi_dim__dim_ibk_sz_bill_config_base',
    email=['rongguangfan@jtexpress.com','yl_bigdata@yl-scm.com'],
    master='yarn',
    name='spmi_dim__dim_ibk_sz_bill_config_base_{{ execution_date | date_add(1) | cst_ds }}',
    sql='spmi/dim/spmi/dim_ibk_sz_bill_config_base/execute.sql',
    # sql='hdfs://yl-bg-hdp:8020/kumiler/hook/sql/execute.sql',
    pool_slots=2,
    executor_cores=2,
    executor_memory='3G',
    num_executors=2,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 32,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '1G',
          'spark.yarn.maxAppAttempts'                        : 1,
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 10,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 10,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=30),
    retries=1,
)

spmi_dim__dim_ibk_sz_bill_config_base << [spmi_ods__ibk_sz_bill_config]